package com.nf.recruitment.controller;

import com.nf.recruitment.dto.CandidateDTO;
import com.nf.recruitment.dto.CandidatePageDTO;
import com.nf.recruitment.dto.CandidateStatusDTO;
import com.nf.recruitment.entity.*;
import com.nf.recruitment.service.CandidateService;
import com.nf.recruitment.vo.ResultVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author
 * @date 2021/6/24
 */
@RestController
@RequestMapping("/candidate")
public class CandidateController extends BaseController {
    @Autowired
    private CandidateService service;

    @GetMapping("/list")
    public ResultVO<List<CandidateDTO>> listCandidate(int page, int limit, int post, int degree) {
        CandidatePageDTO pageDTO = service.listCandidate(page, limit, post, degree);
        return pageResult(pageDTO.getTotal(), pageDTO.getList());
    }

    @PostMapping("/save")
    public ResultVO saveCandidate(@RequestBody Candidate dto) {
        service.saveCandidate(dto);
        return success();
    }
    @PostMapping("/change")
    public ResultVO changeCandidate(@RequestBody CandidateStatusDTO dto) {
        service.changeStatus(dto);
        return success();
    }

}
